package file;

import java.util.ArrayList;
import java.util.Observable;

public class File extends Observable{

	private String idFile;
	private String name;
	private long size;
	private long pieceSize;
	private BufferMap bufferMap;
	private String path;
	private ArrayList<CoupleIpPort> peers;
	private BufferMap dispo;


	public File(){
		this.peers = new ArrayList<CoupleIpPort>();
		this.dispo = new BufferMap();
	}
	
	/**
	 * @return the idFile
	 */
	public String getIdFile() {
		return idFile;
	}

	/**
	 * @param idFile the idFile to set
	 */
	public void setIdFile(String idFile) {
		this.idFile = idFile;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the size
	 */
	public long getSize() {
		return size;
	}

	/**
	 * @param size the size to set
	 */
	public void setSize(long size) {
		this.size = size;
	}

	/**
	 * @return the pieceSize
	 */
	public long getPieceSize() {
		return pieceSize;
	}

	/**
	 * @param pieceSize the pieceSize to set
	 */
	public void setPieceSize(long pieceSize) {
		this.pieceSize = pieceSize;
	}
	public BufferMap getBufferMap() {
		return bufferMap;
	}

	public void setBufferMap(BufferMap bufferMap) {
		this.bufferMap = bufferMap;
		this.dispo.getBufferMap().or(bufferMap.getBufferMap());
	}

//	public BufferMap getBufferMap() {
//		return bufferMap;
//	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getPath() {
		return path;
	}

	/**
	 * @return the peers
	 */
	public final ArrayList<CoupleIpPort> getPeers() {
		return peers;
	}
	
	public BufferMap getDispo() {
		return dispo;
	}
	
	public void setDispo(BufferMap b){
		this.dispo.getBufferMap().or(b.getBufferMap());
		setChanged();
		notifyObservers(this);
	}

	public String toString(){
			return this.idFile + " " + this.name + " " + this.path + " " +this.pieceSize + " " +this.size;
	}
}
